using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;

namespace DungeonOfDespair
{
    public class Entity
    {
        protected bool m_bActive;
        protected int m_iPositionX;
        protected int m_iPositionY;
        private RectangleF m_rectBounds;
        private RectangleF m_rectBoundsAbsolute;

        public Entity()
        {
            m_bActive = true;
            m_iPositionX = 0;
            m_iPositionY = 0;
            m_rectBounds = new RectangleF();
            m_rectBoundsAbsolute = new RectangleF();
        }

        public bool CollidingWith(Entity entity)
        {
            return m_rectBoundsAbsolute.IntersectsWith(
                entity.m_rectBoundsAbsolute);
        }

        public virtual void Update()
        {
            m_rectBoundsAbsolute.X = m_iPositionX + m_rectBounds.X;
            m_rectBoundsAbsolute.Y = m_iPositionY + m_rectBounds.Y;
        }

        public virtual void Draw(Graphics graphics)
        {
        }

        public bool Active
        {
            get { return m_bActive; }
            set { m_bActive = value; }
        }

        public int X
        {
            get { return m_iPositionX;  }
            set { m_iPositionX = value; }
        }

        public int Y
        {
            get { return m_iPositionY; }
            set { m_iPositionY = value; }
        }

        public RectangleF Bounds
        {
            get { return m_rectBounds; }
            set
            {
                m_rectBounds = value;
                m_rectBoundsAbsolute.Width = m_rectBounds.Width;
                m_rectBoundsAbsolute.Height = m_rectBounds.Height;
            }
        }
    }
}
